import request from "@/request";
import { AxiosResponse } from "axios";
import { ResponseData } from "@/types/api/public";
import ResultEnum from "@/config/ResultEnum";

export const cols = [
  {
    title: "部门",
    dataIndex: "deptName",
    key: "deptName",
  },
  {
    title: "操作",
    width: "180px",
    key: "actions",
  },
];

export const getDepts = () => {
  return new Promise((resolve: any, reject: any) => {
    request({
      url: "/dept/tree",
      method: "get",
    }).then((res: any) => {
      if (res.code == ResultEnum.SUCCESS_CODE) {
        resolve(res.result);
      } else {
        reject(res.message);
      }
    });
  });
};

export const delDept = (id: string) => {
  return new Promise((resolve: any, reject: any) => {
    request({
      url: "/dept/" + id,
      method: "delete",
    }).then((res: any) => {
      if (res.code == ResultEnum.SUCCESS_CODE) {
        resolve(res.result);
      } else {
        reject(res.message);
      }
    });
  });
};
